package com.yu.admin.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.admin.modules.system.mapper.LoginLogMapper;
import com.yu.admin.modules.system.pojo.LoginLog;
import com.yu.admin.modules.system.service.LoginLogService;
import com.yu.common.exception.ServiceException;
import com.yu.admin.common.util.session.AdminSessionUtil;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class LoginLogServiceImpl implements LoginLogService {

    @Resource
    private LoginLogMapper loginLogMapper;


    @Override
    public Page<LoginLog> getLoginLogByPage(int pageNo, int pageSize) throws ServiceException {
        Page<LoginLog> page = new Page<>(pageNo, pageSize);
        return loginLogMapper.selectPage(page,
                new QueryWrapper<LoginLog>()
                        .orderByDesc("timestamp"));
    }
}
